#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+7,inf=1e18;
int n,m,a,b,dis[N][2],d[N],vs[N];
vector<int>e[N],f[N];
priority_queue<pair<int,int>>q;
bool vis[N][2];
queue<int>Q;
signed main(){
    freopen("edge.in","r",stdin);
    freopen("edge.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cin>>n>>m>>a>>b;
    b=min(b,2*a);
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    for(int i=1;i<=n;i++){
         dis[i][0]=dis[i][1]=d[i]=inf;
         f[i]=e[i];
    }
    d[1]=0;
    Q.push(1);
    while(!Q.empty()){
        int u=Q.front();Q.pop();
        for(auto v:e[u])vs[v]=u;
        for(auto v:e[u]){
            vector<int>nw={};
            for(auto w:f[v]){
                if(vs[w]==u)nw.emplace_back(w);
                else if(d[w]>d[u]+b){
                    d[w]=d[u]+b;
                    Q.push(w);
                }
            }
            f[v].swap(nw);
        }
    }
    dis[1][0]=0;
    q.push({0,1});
    while(!q.empty()){
        int id=q.top().second;
        q.pop();
        if(!vis[id][0]){
            for(auto v:e[id]){
                if(dis[v][0]>dis[id][0]+1){
                    dis[v][0]=dis[id][0]+1;
                    q.push({-dis[v][0],v});
                }
            }
            vis[id][0]=1;
        }
    }
    dis[1][1]=0;
    for(int i=2;i<=n;i++){
        int ans1=(dis[i][0]/2)*b+(dis[i][0]%2)*a;
        cout<<min(ans1,d[i])<<"\n";
    }
    return 0;
}
